import { Controller, Get, Post, Body, UseGuards } from '@nestjs/common';
import { SequenceService } from '@/services/sequence.service';
import { JwtAuthGuard } from '@/guards/jwt-auth.guard';
import { GenerateSequenceDto } from '@/dto/sequence.dto';

@Controller('sequence-demo')
@UseGuards(JwtAuthGuard)
export class SequenceDemoController {
    constructor(private readonly sequenceService: SequenceService) {}

    /**
     * 演示生成订单号
     */
    @Post('order')
    async generateOrderNumber() {
        return await this.sequenceService.generateNext({
            type: 'ORDER',
            step: 1,
            digits: 6,
            description: '订单号序列',
        });
    }

    /**
     * 演示生成用户ID
     */
    @Post('user')
    async generateUserId() {
        return await this.sequenceService.generateNext({
            type: 'USER',
            step: 1,
            digits: 8,
            description: '用户ID序列',
        });
    }

    /**
     * 演示生成发票号
     */
    @Post('invoice')
    async generateInvoiceNumber() {
        return await this.sequenceService.generateNext({
            type: 'INVOICE',
            step: 1,
            digits: 5,
            description: '发票号序列',
        });
    }

    /**
     * 演示批量生成序列号
     */
    @Post('batch')
    async generateBatch(@Body() config: GenerateSequenceDto) {
        return await this.sequenceService.generateBatch(config, 5);
    }

    /**
     * 获取统计信息
     */
    @Get('stats')
    async getStats() {
        return await this.sequenceService.getStatistics();
    }
}
